package stateAAs.fusions {
	import org.agony2d.gpu.core.ImageAA;
	import org.agony2d.gpu.FusionAA;
	import org.agony2d.gpu.StateAA;
	import org.agony2d.gpu.TingedImageAA;
	import org.agony2d.gpu.UntingedImageAA;
	import org.agony2d.input.KeyboardManager;
	import org.agony2d.notify.AEvent;
	
public class Fusion_StateAA_2 extends StateAA {
  
	/** overwritable... */
	override public function get smoothing() : Boolean {
		return true
	}
	
	/** overwritable... */
	override public function get tinted() : Boolean {
		return true
	}
	
	/** overwrite... */
	override public function get fullTex() : String {
		return "A_64"
	}
	
	/** overwrite... */
	override public function enter() : void {
		
		var index:int = 200
		var i:int
		
		{
			mFusionA = new FusionAA
			this.group.addNode(mFusionA)
			
			{
				while (i < mLen) {
					tintImg = new TingedImageAA
					mFusionA.addNode(tintImg)
					tintImg.textureData = FULL_TEX
					tintImg.x = index
					tintImg.y = 200
					index += 32
					tintImg.color = 0xFFFFFF * Math.random()
					i++
				}
				
				mImgA = new TingedImageAA
				mFusionA.addNodeAt(mImgA, 0)
				mImgA.textureData = FULL_TEX
				mImgA.x = 220
				mImgA.y = 200
				mImgA.scaleX = mImgA.scaleY = 3
				
			}
		}
		KeyboardManager.getInstance().getState().release.addEventListener("Q", onSwap)
		KeyboardManager.getInstance().getState().release.addEventListener("T", onTex)
	}
	
	override public function exit():void {
		KeyboardManager.getInstance().getState().release.removeEventListener("Q", onSwap)
		KeyboardManager.getInstance().getState().release.removeEventListener("T", onTex)
	}
	
	
	private var mImgA:TingedImageAA
	private var mFusionA:FusionAA
	private var mIndex:int, mLen:int = 5
	private var tintImg:TingedImageAA
	
	private function onSwap(e:AEvent):void {
		if (++mIndex > 5) {
			mIndex = 0
		}
		mFusionA.addNodeAt(mImgA, mIndex)
	}
	
	private function onTex(e:AEvent):void {
		mFusionA.swapNodes(mImgA, tintImg)
	}
}
}